package com.xcity.pomelo.response;

import com.xcity.db.entity.Player;
import com.xcity.game.buff.Buff;
import com.xcity.game.buff.BuffEffector;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.common.PlayerPool;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@Deprecated
@PomeloMessage(type = Message.Type.RESPONSE)
public class CheckItemTimeResponse extends Response {

	private int buildSpeed;
	private int bsRemainingTime; // 加速道具剩余有效时间
	private byte isProtect; // 是否受到资产保护(1:是; 0:否)
	private int ipRemainingTime; // 资产保护剩余有效时间

	public CheckItemTimeResponse(int serial, Player player) {
		super(serial);
		int reduceCD = player.getPool().getIntValue(PlayerPool.PROPERTY_BUILD_SPEED_UP_REDUCE_CD);
		if (reduceCD <= 0) {
			reduceCD = GameStaticConfig.speedUpReduceCD;
		}
		buildSpeed = reduceCD / 1000;
		Buff buff = player.getBuffs().getBuffByEffect(BuffEffector.BUFF_REDUCE_BUILD_CD);
		if (buff != null) {
			bsRemainingTime = buff.getLeftCD();
		}
		isProtect = (byte) (player.getPool().getBooleanValue(PlayerPool.PROPERTY_ASSETS_BE_PROTECTED) ? 1 : 0);
		if (isProtect == 1
				&& (buff = player.getBuffs().getBuffByEffect(BuffEffector.BUFF_PROTECT_ASSETS)) != null) {
			ipRemainingTime = buff.getLeftCD();
		}
	}
	
	public int getBuildSpeed() {
		return buildSpeed;
	}

	public void setBuildSpeed(int buildSpeed) {
		this.buildSpeed = buildSpeed;
	}

	public int getBsRemainingTime() {
		return bsRemainingTime;
	}

	public void setBsRemainingTime(int bsRemainingTime) {
		this.bsRemainingTime = bsRemainingTime;
	}

	public byte getIsProtect() {
		return isProtect;
	}

	public void setIsProtect(byte isProtect) {
		this.isProtect = isProtect;
	}

	public int getIpRemainingTime() {
		return ipRemainingTime;
	}

	public void setIpRemainingTime(int ipRemainingTime) {
		this.ipRemainingTime = ipRemainingTime;
	}

}
